<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript">
        //constructor method
        /**
        * 构造函数(类)/普通函数
        * 1.普通函数直接调用
        * 2.构造函数通过new关键字调用
        */
        function Person(name,age,gender){
            this.name = name;
            this.age = age;
            this.gender = gender;
            this.sayName = function(){
                console.log(this.name);
            }
        }
        var peter =  new Person("Peter",18,"male")
        // 类（构造函数）的修改
        Person.prototype.sayAge = function(){
            console.log(this.age);
        }
        var josh = new Person("Josh",19,"male");
        peter.sayAge()
        josh.sayAge();


    </script>
</head>
<body>
    
</body>
</html>